package com.yupi.generator;

import cn.hutool.core.io.FileUtil;

import java.io.File;

/**
 * 静态文件生成器:只能全部复制，不能指定文件复制。【递归遍历可以屏蔽一些简单的。】
 * 1. 使用hutool工具类的方法实现复制FileUtil.copy()
 * 2. 复制源地址、输出地址
 */
public class StaticGenerator {
    public static void main(String[] args) {
       //Get the path of the current directory
        String propertyPath = System.getProperty("user.dir");
        System.out.println(propertyPath);
        //Get the parent file of the current directory
        File parentFile = new File(propertyPath).getParentFile();
        //Get the absolute path of the parent file
        String inputPath = new File(parentFile, "yuzi-generator/yuzi-generator-demo-projects/acm-template").getAbsolutePath();
        //Get the absolute path of the current directory
        String outputPath = propertyPath;
        copyFilesByHutool(inputPath,outputPath);
        System.out.println(inputPath);//F:\Planet project\yuzi-generator\yuzi-generator-demo-projects\acm-template
        System.out.println(outputPath);//F:\Planet project\yuzi-generator


    }

    /**
     * 拷贝文件（Huttol实现，会将输入目录完整拷贝到输出目录下）
     * @param inputPath
     * @param outputPath
     */
    public static void copyFilesByHutool(String inputPath,String outputPath){
        FileUtil.copy(inputPath, outputPath, true);
    }

}
